<template>
  <div class="org-lazy-tree">
    <el-tree
      ref="tree"
      :load="handleLoadNode"
      :props="{ label: 'name' }"
      v-bind="$attrs"
      show-checkbox
      node-key="phid"
      lazy
    />
    <!-- :render-content="treeRender" -->
  </div>
</template>

<script>
import { listOrgByParentId } from '@/api/organization'

export default {
  data() {
    return {
      treeData: []
    }
  },
  methods: {
    handleLoadNode(node, resolve) {
      if (node.level === 0) {
        listOrgByParentId({ parentId: 0 }).then(res => {
          resolve(res.data)
        })
      } else {
        listOrgByParentId({ parentId: node.data.phid }).then(res => {
          resolve(res.data)
        })
      }
    }
  }
}
</script>

<style>

</style>
